﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using HK2009.BusinessFacade;
using HK2009.EntityManage;
using HK2009.Common;
using HK2009.EntityQuery;
using System.Data;

namespace HK2009.BusinessFacadeHandler
{
    public class SyContainerModelHandler : ISyContainerModelHandler
    {
        DataBase db = new DataBase();
        Sy_ContainerModelManage modelManage = new Sy_ContainerModelManage();


        /// <summary>
        /// 根据sql语句同参数获取权限列表
        /// </summary>
        /// <param name="sqlStr">sql语句</param>
        /// <param name="parms">参数</param>
        /// <returns></returns>
        public DataTable GetModelList(string sqlStr, SqlParameter[] parms)
        {
            return db.RunSqlTab(sqlStr, parms);
        }

        /// <summary>
        /// 根据pkID获取Model
        /// </summary>
        /// <param name="pkID"></param>
        /// <returns></returns>
        public Sy_ContainerModelQuery GetModel(int pkID)
        {
            return modelManage.GetSy_ContainerModelQuery(pkID);
        }

        /// <summary>
        /// 根据name获取柜型
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public DataTable GetModelList(string name)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0] = new SqlParameter("@Model", name);
            return modelManage.GetSy_ContainerModelList(" Model=@Model", parms);
        }


        /// <summary>
        /// 根据pkID删除柜型
        /// </summary>
        /// <param name="pkID"></param>
        /// <returns></returns>
        public bool ModelDelete(int pkID)
        {
            return modelManage.DeleteSy_ContainerModel(pkID);
        }

        /// <summary>
        /// 传入实体类进行更新
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public bool ModelUpdate(Sy_ContainerModelQuery query)
        {
            return modelManage.UpdateSy_ContainerModel(query);
        }

        /// <summary>
        /// 传入实体进行添加
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public bool ModelInsert(Sy_ContainerModelQuery query)
        {
            return modelManage.InsertSy_ContainerModel(query);
        }
    }
}
